$(function() {
	var content = '';
	var token = localStorage.phone;
	var order_id = localStorage.order_id;
	$('span[name=sure]').click(function() {
		content = $('textarea[name=content]').val();
		if(content != '') {
			$.ajax({
				url: "https://newapp.icandrive.cn/api/comments.php",
				type: 'post',
				data: {
					content: content,
					token: token,
					order_id: order_id
				},
				dataType: 'json',
				success: function(data) {
					if(data.status == 200) {
						layer.msg('评价成功');
						history.back();
					}
				},
				error: function() {
					layer.msg('系统繁忙', function() {
						history.go(0)
					}, 1000);
				}

			})
		} else {
			layer.msg('请输入评价内容');
		}

	})
})

/*监听手机返回键功能*/
document.addEventListener("plusready", function() {
	// 注册返回按键事件
	plus.key.addEventListener('backbutton', function() {
		localStorage.clear();
		window.history.back();
	}, false);
	//此处false代表不退出页面，如果为true回退到上一个一面
});
